﻿$(document).ready(function () {
    $("#login-btn").on("click", function() {
        if (loginValidate()) {
            var data = { phoneNumber: $("#phoneNumber").val(), inputPassword: $("#inputPassword").val() };
            var url = "../Handle/AdminHandlerService.ashx?method=Ad_Verification_User_Log";
            $.ajax({
                type: "POST",
                data: data,
                url: url,
                dataType: "json",
                success: function (d) {
                    if (1 == d.MessageType) {
                        top.location = "CommunicateList.aspx";
                    } else {
                        // alert("登录信息错误，请重新登录！");
                        $("#dialog-modal-label").text("登录信息错误，请重新登录！");
                        $("#DialogModal").modal("show");
                    }
                    //console.log(data);
                }
            });
        }
    });
    
});

function loginValidate() {
    return $("#login-form").validate({
        errorClass: "warning",
        rules: {
            phoneNumber: {
                required: true,
               // digits:true,
                minlength: 11,
                maxlength: 11
            },
            inputPassword: {
                required: true,
                minlength: 5
            }
        },
        messages: {
            phoneNumber: {
                required: "请输入电话号码",
              //  digits: "电话号码是数字",
                minlength: "电话号码有11位数字",
                maxlength: "电话号码有11位数字"
            },
            inputPassword: {
                required: "请输入密码",
                minlength: "密码长度不能小于 5 个字母"
            }
        }
    }).form();
}
